package main

type AgencyHierarchy struct {
	ID       int `json:"id"`
	ParentID int `json:"parent_id"`
	UserID   int `json:"user_id"`
	// 代理编号 10240 开始
	Code int `json:"code"`
	Lft  int `json:"left"`
	Rgt  int `json:"right"`
}

func (AgencyHierarchy) TableTable() string {
	return "agency_hierarchy"
}

/*
LOCK TABLE nested_category WRITE;
SELECT @myLeft := lft FROM nested_category WHERE name = 'Beef';
UPDATE nested_category SET rgt = rgt + 2 WHERE rgt > @myLeft;
UPDATE nested_category SET lft = lft + 2 WHERE lft > @myLeft;
INSERT INTO nested_category(name, lft, rgt) VALUES('charqui', @myLeft + 1, @myLeft + 2);
UNLOCK TABLES;
*/
func (AgencyHierarchy) AddChild(node AgencyHierarchy, newNode AgencyHierarchy) error {
	return nil
}

/*
LOCK TABLE nested_category WRITE;
SELECT @myRight := rgt FROM nested_category WHERE name = 'Cherry';
UPDATE nested_category SET rgt = rgt + 2 WHERE rgt > @myRight;
UPDATE nested_category SET lft = lft + 2 WHERE lft > @myRight;
INSERT INTO nested_category(name, lft, rgt) VALUES('Strawberry', @myRight + 1, @myRight + 2);
UNLOCK TABLES;
*/
func (AgencyHierarchy) AddSibling(node AgencyHierarchy) error {
	return nil
}

/*
LOCK TABLE nested_category WRITE;
SELECT @myLeft := lft, @myRight := rgt, @myWidth := rgt - lft + 1
FROM nested_category WHERE name = 'Cherry';
DELETE FROM nested_category WHERE lft BETWEEN @myLeft AND @myRight;
UPDATE nested_category SET rgt = rgt - @myWidth WHERE rgt > @myRight;
UPDATE nested_category SET lft = lft - @myWidth WHERE lft > @myRight;
UNLOCK TABLES;
*/
func (AgencyHierarchy) Delete(node AgencyHierarchy) error {
	return nil
}
